import { MessagePlugin } from 'tdesign-vue-next';

// 设置节流
let fleg = null;
export default (el: any, doms: string) => {
  const element = document.getElementById(doms);
  console.log(element);

  el.addEventListener('wheel', (e) => {
    // console.log('wheel', element.scrollWidth, element.clientWidth);

    if (element.scrollWidth > element.clientWidth) {
      e.preventDefault();
      if (el.scrollLeft >= element.scrollWidth - element.clientWidth) {
        if (!fleg) {
          MessagePlugin.warning('暂无更多内容');
          fleg = setTimeout(() => {
            fleg = null;
          }, 1000);
        }
      }
    } else {
    }

    if (e.wheelDelta > 0) {
      el.scrollLeft -= 100;
    } else {
      el.scrollLeft += 100;
    }
  });
};
